
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%--
  Created by IntelliJ IDEA.
  User: l
  Date: 2022/5/26
  Time: 17:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE>
<html>
<head>
    <title>管理后台</title>
    <link href="css/admin.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="header">
    <div id="welcome">欢迎使用新闻管理系统！</div>
    <div id="nav">
        <div id="logo"><img src="images/logo.jpg" alt="新闻中国"/></div>
        <div id="a_b01"><img src="images/a_b01.gif" alt=""/></div>
    </div>
</div>

<div id="admin_bar">
    <div id="status">
        管理员：${currentUser.uname} 登录 &#160;&#160;&#160;&#160;
        <a href="LoginoutServlet">login out</a>
        当前在线的有 ${fn:length(currentUserList)} 个人:
        <c:forEach var="newsUsers" items="${currentUserList}">
            <a href="#">${newsUsers.uname}</a>
        </c:forEach>
    </div>
    <div id="channel"></div>
</div>
<div id="main">
    <div id="opt_list">
        <ul>
            <li><a href="news_add.jsp">添加新闻</a></li>
            <li><a href="#">编辑新闻</a></li>
            <li><a href="#">查找新闻</a></li>
            <li><a href="topic_add.jsp">添加主题</a></li>
            <li><a href="topicList.jsp">编辑主题</a></li>
            <li><a href="productList.jsp">购买商品</a></li>
            <li><a href="updateUser.jsp">修改个人资料</a></li>
        </ul>
    </div>
    <div id="opt_area">
        <script>
            function clickdel(nid) {
                if (confirm("删除请点击确认")) {
                    location.href = "DeleteNewsServlet?nid=" + nid;
                }
            }
        </script>
        <ul>
            <c:forEach var="news" items="${listNews}" varStatus="status">
                <li>
                    <a href="GetOneNewsByNidServlet?nid=${news.nid}"
                       target="_blank">${news.ntitle}
                    </a>
                    <span style="float: right">作者: ${news.nauthor}
                <a href="NewsEditGetDataServlet?nid=${news.nid}">修改</a>
                <a href="javascript:clickdel(${news.nid});">删除</a>
                </span>
                </li>
                <c:if test="${status.count%5==0}">
                    <li>&nbsp;</li>
                </c:if>
            </c:forEach>
            <p>
                <c:if test="${p.currentPage>1}">
                    <a href="GetSomeNewsByPageServlet?currentPage=<%= 1%>">第一页</a>
                    <a href="GetSomeNewsByPageServlet?currentPage=${p.currentPage-1}">上一页</a>
                </c:if>
                <c:if test="${p.currentPage<p.pages}">
                    <a href="GetSomeNewsByPageServlet?currentPage=${p.currentPage+1}">下一页</a>
                    <a href="GetSomeNewsByPageServlet?currentPage=${p.pages}">最后一页</a>
                </c:if>
            </p>
            <p>
                <c:forEach var="i" begin="1" end="${p.pages}" step="1">
                    <a href="GetSomeNewsByPageServlet?currentPage=${i}" <c:if test="${i==p.currentPage}">class="blue"</c:if>>${i}</a>
                </c:forEach>
            </p>
            <script src="js/jquery-3.6.0.js"></script>
            <script>
                $(function () {
                    $("#jumpBtn").click(function () {
                        location.href = "GetSomeNewsByPageServlet?currentPage=" + $("#currentPage").val()
                    });
                });
            </script>
            <p>
                <button id="jumpBtn">跳转</button>
                到
                <select id="currentPage" name="currentPage">
                    <c:forEach var="i" begin="1" end="${p.pages}" step="1">
                        <option value="${i}" <c:if test="${i==p.currentPage}">selected</c:if>>${i}</option>
                    </c:forEach>
                </select>
                页
            </p>
        </ul>
    </div>
</div>
<div id="site_link">
    <a href="">关于我们</a><span>|</span>
    <a href="">Aboue Us</a><span>|</span>
    <a href="">联系我们</a><span>|</span>
    <a href="">广告服务</a><span>|</span>
    <a href="">供稿服务</a><span>|</span>
    <a href="">法律声明</a><span>|</span>
    <a href="">招聘信息</a><span>|</span>
    <a href="">网站地图</a><span>|</span>
    <a href="">留言反馈</a>
</div>
</body>
</html>
